﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ValidationHelper.Validators
{
    public class RangeValidator : NumericValidator
    {
        #region Propriedades
        public double MinimalValue { get; set; }
        public double MaximumValue { get; set; }
        public bool IncludeLimits { get; set; }
        #endregion

        #region Construtores
        public RangeValidator(string message, Type exceptionType, double numberToValidate, double minimalValue, double maximumValue, bool includeLimits)
            : base(message, exceptionType, numberToValidate)
        {
            MinimalValue = minimalValue;
            MaximumValue = maximumValue;
            IncludeLimits = includeLimits;
        }
        #endregion

        #region Métodos
        protected override bool IsNotValid()
        {
            if (IncludeLimits)
            {
                return !(NumberToValidate >= MinimalValue && NumberToValidate <= MaximumValue);
            }
            else
            {
                return !(NumberToValidate > MinimalValue && NumberToValidate < MaximumValue);
            }
        }
        #endregion
    }
}
